package com.five.taotao.setup;

import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AutoCompleteTextView;
import android.widget.PopupWindow;
import android.widget.Toast;

import com.five.taotao.R;

import butterknife.ButterKnife;
import butterknife.OnClick;

public class AboutusActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_aboutus);
        ButterKnife.bind(this);
    }
  @OnClick(R.id.back)
    public void back(View v){
        finish();
    }
    @OnClick(R.id.item1)
    public void vision(View v){
        Toast.makeText(this, "当前版本为最新", Toast.LENGTH_SHORT).show();
    }

    @OnClick(R.id.item2)
    public  void guanzhu(View v){
        Intent intent=new Intent(this,GuanzhuActivity.class);
        startActivity(intent);
    }
    @OnClick(R.id.item3)
    public  void tuijian(View v){
        View view= LayoutInflater.from(this)
                .inflate(R.layout.share_popupwindow,null,false);
        final PopupWindow popupWindow=new PopupWindow(view,
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT );

        //分享QQ好友图标
        view.findViewById(R.id.shareqq).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        //点击空白处，popupWindow消失。（6.0以上不用设置这些代码）
        popupWindow.setFocusable(true);
        popupWindow.setOutsideTouchable(true);
        //实例化一个ColorDrawable颜色为半透明
        ColorDrawable dw = new ColorDrawable(0x00000000);
        //设置SelectPicPopupWindow弹出窗体的背景
        popupWindow.setBackgroundDrawable(dw);
        backgroundAlpha(this, 0.5f);//0.0-1.0
        popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                backgroundAlpha(AboutusActivity.this, 1f);
            }
        });

        //这些设置代码必须放在showZtLocation方法之前
        popupWindow.showAtLocation(v,
                Gravity.CENTER,
                0,
                0);
        popupWindow.showAsDropDown(v);
    }

    /**
     * 设置添加屏幕的背景透明度
     * @param bgAlpha
     */
    public void backgroundAlpha(Activity context, float bgAlpha)
    {
        WindowManager.LayoutParams lp = context.getWindow().getAttributes();
        lp.alpha = bgAlpha;
        context.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        context.getWindow().setAttributes(lp);
    }

}
